

#include <stdint.h>

#define  RCC_CR       		    (*(volatile uint32_t *) 0x40021000)
#define  RCC_CFGR       		(*(volatile uint32_t *) 0x40021008)
#define  RCC_CIER      		    (*(volatile uint32_t *) 0x40021088)
#define  RCC_AHB2ENR      		 (*(volatile uint32_t *) 0x4002104C)

#define  GPIOE     				(*(volatile uint32_t *) 0x48001000)
#define  GPIOE_MODER			(*(volatile uint32_t *) 0x48001000)
#define  GPIOE_OTYPER			(*(volatile uint32_t *) 0x48001004)
#define  GPIOE_OSPEEDR			(*(volatile uint32_t *) 0x48001008)
#define  GPIOE_PUPDR			(*(volatile uint32_t *) 0x4800100C)
#define  GPIOE_ODR				(*(volatile uint32_t *) 0x48001014)



void SystemInit(void)
{
	
	RCC_CR  |=   1<<3;  //select msi range from RCC_CR[7:4]
	RCC_CR  |=   0x7 << 4;  //configure msi clk as 8mHz
	
	RCC_CFGR  &= 	~(0x3 << 0);   //select MSI as sys_clk source;
	
	RCC_CR |=  1<<0; //enable mis clk;
	while( (RCC_CR & 0x02) ==0);   //wait until  MSI clk enabled;
}


void light_red_led(){
	
	//enable gpioe  clock
	RCC_AHB2ENR  |= 1<<4;

	//config  gpioe-7 as output 
	GPIOE_MODER = 0;
	GPIOE_MODER |=  (0x01 << 14);   //output
	GPIOE_OTYPER  &=  ~(1<<7);   //push-pull
	GPIOE_PUPDR &= ~(0x03 <<7);  //no pull up-down.
	GPIOE_ODR   &= ~(1<<7); //light  Red led
}
	
int main(){

    light_red_led();
    while(1);
	
}
